package cn.edu.javaweb.userServlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.javaweb.utils.DBUtil;


@WebServlet("/PersonalServlet")
public class PersonalServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	DBUtil db;
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		db=new DBUtil(); //建创对象 搭桥配置初始化
		HttpSession session = request.getSession(true);
		String id = (String)session.getAttribute("id");
		String sql="select * from user where id="+id;  //写入sql语句
		System.out.println(sql);
		Map map=db.getMap(sql);
		System.out.println(map);
		String realname=(String) map.get("realname");
		request.setAttribute("realname",realname);
		String uclass=(String) map.get("uclass");
		request.setAttribute("uclass",uclass);
		String pricture=(String) map.get("pricture");
		request.setAttribute("pricture",pricture);
		String sex=(String) map.get("sex");
		request.setAttribute("sex",sex);
		request.getRequestDispatcher("volunteer/user/Personal.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}

}
